﻿@{
    Layout = null;
}
@model ElingOA6_Admin_DSJCJ.Model.HREmpl
<!DOCTYPE html>
<html>
@Html.Partial("LoadPanelPartial")
<head>
    @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/FloatDiv.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/regex.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>

    @Html.DevExpress().GetStyleSheets(

        new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }
)
    @Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox }
)

    <script type="text/javascript">
        $(function () {

            $("#toolMenu").smartFloat();

            var message = $('#hidMessage').val();
            if (message != "") {
                alert(message);
            }

            // hidDeptPosition  hidDeptPositionMain
            var deptPosition = $('#hidDeptPosition').val();
            var deptPositionHtml = $('#hidDeptPositionHtml').val();
            if (deptPosition != "" && deptPositionHtml != "") {
                $('#tbPosition').html("");
                $('#tbPosition').html(deptPositionHtml);
            } else {
                $('#hidDeptPosition').val('');
                $('#hidDeptPositionHtml').val('');
            }




        });
        function MenuTop_emClick(source, e) {
            switch (e.item.name) {
                case "btnSave":
                    {
                        //保存
                        $('#hidSaveType').val("save");
                        save();
                        break;
                    }
                case "btnSaveAdd":
                    {
                        //保存并新增
                        $('#hidSaveType').val("saveAdd");
                        save();
                        break;
                    }
                case "btnCancel":
                    {
                        //取消
                        window.location.href = rootPath + "/Admin/Empl/EmplList";
                        break;
                    }
            }
        }

        function selectPosition() {
            positonModalMode.Show();
        }

        //岗位选择确定
        function PositionOK(deptPositionNo, deptPositionName) {
            var nos = "";
            var bl = true;
            $('#tbPosition').html('');
            for (var i = 0; i < deptPositionNo.length; i++) {
                nos += deptPositionNo[i] + "&";
                if (bl) {
                    $('#tbPosition').append("<input type='radio' name='positonNo' value='" + deptPositionNo[i] + "' checked/>" + deptPositionName[i] + "<br />");
                    bl = false;
                } else {
                    $('#tbPosition').append("<input type='radio' name='positonNo' value='" + deptPositionNo[i] + "' />" + deptPositionName[i] + "<br />");
                }
            }
            if (nos != "") {
                nos = nos.substr(0, nos.length - 1);
            }
            $('#hidDeptPosition').val(nos);
            $('#hidDeptPositionHtml').val($('#tbPosition').html());
            positonModalMode.Hide();
        }

        //岗位选择取消
        function PositionCancel() {
            positonModalMode.Hide();
        }

        function save() {
            lpModal.Show();
            var empNo = FEmplNo.GetText();
            var empName = FEmpName.GetText();
            var dutyNo = FDutyNo.GetValue();
            var seq = FSeq.GetText();

            if (pd(empNo, empName, dutyNo, seq)) {

                var nos = $('#hidDeptPosition').val();
                if ($('#hidEmplNo').val() == "")//增加时判断编号是否已存在
                {
                    $.ajax({
                        type: 'POST',
                        url: rootPath + '/Admin/Empl/ExistsEmp',
                        data: { empNo: empNo },
                        success: function (result) {
                            if (result == "N") {
                                if (nos == "") {
                                    alert("请选择岗位!");
                                    lpModal.Hide();
                                } else {
                                    save1(nos, empNo);
                                }
                            } else if (result == "Y") {
                                FEmplNo.SetErrorText("编号已存在");
                                FEmplNo.SetIsValid(false);
                                lpModal.Hide();
                            } else {
                                alert("判断编号是否已存在参数错误");
                                lpModal.Hide();
                            }
                        }
                    });
                } else {
                    if (nos == "") {
                        alert("请选择岗位!");
                        lpModal.Hide();
                    } else {
                        save1(nos, empNo);
                    }
                }

            } else {
                lpModal.Hide();
            }


        }

        //保存并判断是否已存在正级岗位绑定数据
        function save1(nos, empNo) {
            $.ajax({
                type: 'POST',
                url: rootPath + '/Admin/Empl/ExistsMainPositon',
                data: { deptPositionNos: nos, empNo: empNo },
                success: function (result) {
                    if (result == "Y") {
                        alert("选择的岗位中存在正级岗位，且其他人员已绑定该正级岗位，请重新选择！");
                        lpModal.Hide();
                    } else if (result == "N") {
                        form1.submit();
                    } else if (result == "error") {
                        form1.submit();
                    } else {
                        form1.submit();
                    }
                }
            });

        }

        function pd(empNo, empName, dutyNo, seq) {
            var bl = true;
            if (empNo == null || ASPxClientUtils.Trim(empNo) == "") {
                FEmplNo.SetErrorText("请填写编号");
                FEmplNo.SetIsValid(false);
                bl = false;
            }

            if (empName == null || ASPxClientUtils.Trim(empName) == "") {
                FEmpName.SetErrorText("请填写姓名");
                FEmpName.SetIsValid(false);
                bl = false;
            }

            if (dutyNo == null || ASPxClientUtils.Trim(dutyNo) == "") {
                FDutyNo.SetErrorText("请选择职务");
                FDutyNo.SetIsValid(false);
                bl = false;
            }

            if (seq == null || ASPxClientUtils.Trim(seq) == "") {
                FSeq.SetErrorText("请填写显示顺序");
                FSeq.SetIsValid(false);
                bl = false;
            } else {
                if (!isNumeric(seq)) {
                    FSeq.SetErrorText("显示顺序必须是整数!");
                    FSeq.SetIsValid(false);
                    bl = false;
                }
            }

            if (bl) {
                var photo = photoUpload.GetText();
                photo = photo.substring(photo.lastIndexOf("."));
                photo = photo.toLowerCase();
                if (photo != "" && photo != ".jpg" && photo != ".jpeg" && photo != ".jpe" && photo != ".gif" && photo != ".bmp") {
                    alert("请上传以下类型图片  .jpg .jpeg .jpe .gif .bmp");
                    bl = false;
                }
            }




            return bl;
        }
    </script>

</head>
<body>
    @using (Html.BeginForm("Save", "Empl", FormMethod.Post, new { id = "form1" }))
    { 
        <div class="floatToolMenu" id="toolMenu">
            @Html.DevExpress().Menu(settings =>
       {
           settings.Name = "toolBarMenu";
           settings.ItemAutoWidth = false;
           settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
           settings.Styles.Style.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
           settings.Styles.Style.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);

           settings.Items.Add(item =>
           {
               item.Name = "btnSave";
               item.Text = "保存";
               item.ClientEnabled = true;
               item.Image.Url = Url.Content("~/Content/ControlImages/filesave.png");

           });
           settings.Items.Add(item =>
           {
               item.Name = "btnSaveAdd";
               item.Text = "保存并新增";
               item.ClientEnabled = true;
               item.Image.Url = Url.Content("~/Content/ControlImages/save_add.png");

           });
           settings.Items.Add(item =>
           {
               item.Name = "btnCancel";
               item.Text = "取消";
               item.ClientEnabled = true;
               item.Image.Url = Url.Content("~/Content/ControlImages/no.png");

           });
           settings.ClientSideEvents.ItemClick = "function(source,e){MenuTop_emClick(source,e)}";
           settings.ItemLinkMode = ItemLinkMode.ContentBounds;
       }).GetHtml()
        </div>
        
        
        <table class="tableForm">
            <tr>
                <th width="15%">
                    编号:
                </th>
                <td colspan="2" class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FEmplNo";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.Text = Model.FEmplNo;
                   settings.Enabled = (bool)ViewData["blemp"];
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()
                    @Html.Hidden("hidEmplNo", Model.FEmplNo)
                </td>
                <td width="35%" rowspan="5">
                    <img alt="" width="100px" height="136px" id="previewImage" src="@Model.FPhotoPath" />
                    @Html.DevExpress().UploadControl(
            settings =>
            {
                settings.Name = "photoUpload";
                settings.BrowseButton.Text = "浏览";
                settings.ClearFileSelectionImage.ToolTip = "清除选择";
                settings.ShowProgressPanel = true;
                //settings.AdvancedModeSettings.EnableMultiSelect = true;
                settings.ValidationSettings.MaxFileSize = 20971520;
                settings.ValidationSettings.AllowedFileExtensions = new string[] { ".jpg", ".jpeg", ".jpe", ".gif", ".png" };
                settings.ShowUploadButton = false;
            }).GetHtml()
                </td>
            </tr>
            <tr>
                <th>
                    姓名:
                </th>
                <td colspan="2" class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FEmpName";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.Text = Model.FEmpName;
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()
                </td>
            </tr>
            <tr>
                <th>
                    身份证:
                </th>
                <td colspan="2" class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FIdNo";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.Text = Model.FIdNo;
               }).GetHtml()
                </td>
            </tr>
            <tr>
                <th>
                    籍贯:
                </th>
                <td colspan="2" class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FNativePlace";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.Text = Model.FNativePlace;
               }).GetHtml()
                </td>
            </tr>
            <tr>
                <th>
                    出生日期:
                </th>
                <td colspan="2" class="tdClass">
                    @Html.DevExpress().DateEdit(settings =>
               {
                   settings.Name = "FBirthday";
                   settings.Properties.NullText = "";
                   settings.Properties.DisplayFormatString = "yyyy-MM-dd";
                   settings.Properties.EditFormatString = "yyyy-MM-dd";
                   if (Model.FBirthday.HasValue)
                   {
                       settings.Date = Model.FBirthday.Value;
                   }

               }).GetHtml()
                </td>
                


            </tr>
            <tr>
                <th>
                    性别:
                </th>
                <td class="tdClass">
                    @Html.DevExpress().RadioButtonList(settings =>
               {
                   settings.Name = "FSex";
                   settings.Properties.RepeatLayout = System.Web.UI.WebControls.RepeatLayout.Table;
                   settings.Properties.RepeatDirection = System.Web.UI.WebControls.RepeatDirection.Horizontal;
                   settings.Properties.RepeatColumns = 2;

               }).BindList(new List<SelectListItem> { new SelectListItem { Text = "男", Value = "男" }, new SelectListItem { Text = "女", Value = "女" } }).Bind(Model.FSex).GetHtml()
                </td>

                <th>
                    登录绑定IP:
                </th>
                <td class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FLoginIPAddress";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.Text = Model.FLoginIPAddress;
                   settings.ToolTip = "格式(xxx.xxx.xxx.xxx)";
               }).GetHtml()
                </td>
                <td colspan="2" class="tdClass">
                    @Html.DevExpress().CheckBox(settings =>
               {
                   settings.Name = "FIsJoin";
                   settings.Text = "参与去向管理";
                   if (Model.FIsJoin == "Y")
                   {
                       settings.Checked = true;
                   }
                   else
                   {
                       settings.Checked = false;
                   }
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.ClientVisible = false;
               }).GetHtml()
                    @Html.DevExpress().CheckBox(settings =>
               {
                   settings.Name = "FIsCheck";
                   settings.Text = "参与绩效考核";
                   if (Model.FIsCheck == "Y")
                   {
                       settings.Checked = true;
                   }
                   else
                   {
                       settings.Checked = false;
                   }
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.ClientVisible = false;
               }).GetHtml()

                 @Html.DevExpress().CheckBox(settings =>
               {
                   settings.Name = "FIsAttendance";
                   settings.Text = "参与网上考勤";
                   if (Model.FIsAttendance == "Y")
                   {
                       settings.Checked = true;
                   }
                   else
                   {
                       settings.Checked = false;
                   }
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.ClientVisible = false;
               }).GetHtml()
               @Html.DevExpress().CheckBox(settings =>
               {
                   settings.Name = "FIsAllowAddtionInsPlan";
                   settings.Text = "允许补录其他人员绩效台账";
                   if (Model.FIsAllowAddtionInsPlan == "Y")
                   {
                       settings.Checked = true;
                   }
                   else
                   {
                       settings.Checked = false;
                   }
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.ClientVisible = false;
               }).GetHtml()
                </td>
            </tr>
            <tr>
                <th width="15%">
                    毕业院校:
                </th>
                <td width="35%" class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FSchool";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.Text = Model.FSchool;
               }).GetHtml()
                </td>
                <th width="15%">
                    学历:
                </th>
                <td width="35%" class="tdClass">
                    @Html.DevExpress().ComboBox(
            settings =>
            {
                settings.Name = "FEduNo";
                settings.Properties.DropDownStyle = DropDownStyle.DropDownList;
                settings.Properties.TextField = "FCodeName";
                settings.Properties.ValueField = "FCodeNo";
            }).BindList(ViewData["eduNoList"]).Bind(Model.FEduNo).GetHtml()
                </td>
            </tr>
            <tr>
                <th>
                    专业:
                </th>
                <td colspan="3" class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FSpecialty";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.Text = Model.FSpecialty;
               }).GetHtml()
                </td>
            </tr>
            <tr>
                <th>
                    办公室电话:
                </th>
                <td class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FOfficeTel";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.Text = Model.FOfficeTel;
               }).GetHtml()
                </td>
                <th>
                    虚拟电话:
                </th>
                <td class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FTelShortNo";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.Text = Model.FTelShortNo;
               }).GetHtml()
                </td>
            </tr>
            <tr>
                <th>
                    手机:
                </th>
                <td class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FMobile";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.Text = Model.FMobile;
               }).GetHtml()
                </td>
                <th>
                    手机虚拟号:
                </th>
                <td class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FMobShortNo";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.Text = Model.FMobShortNo;
               }).GetHtml()
                </td>
            </tr>
            <tr>
                <th>
                    家庭电话:
                </th>
                <td class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FHomeTel";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.Text = Model.FHomeTel;
               }).GetHtml()
                </td>
                <th>
                    电子邮箱:
                </th>
                <td class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FEMail";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.Text = Model.FEMail;
               }).GetHtml()
                </td>
            </tr>
            <tr>
                <th>
                    家庭地址:
                </th>
                <td colspan="3" class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FHomeAddr";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.Text = Model.FHomeAddr;
               }).GetHtml()
                </td>
            </tr>
            <tr>
                <th>
                    在职岗位:
                </th>
                <td id="tbPosition" class="tdClass">
                </td>
                <td align="right" class="tdClass">
                    @Html.DevExpress().Button(settings =>
               {
                   settings.Name = "btnSelect";
                   settings.Text = "选择";
                   //settings.ControlStyle.CssClass = "left";
                   settings.ClientSideEvents.Click = "selectPosition";
               }).GetHtml()
                </td>
                <td class="tdClass">
                    (单选选中的为主岗位) </td>
            </tr>
            <tr>
                <th>
                    职务:
                </th>
                <td colspan="3" class="tdClass">
                    @Html.DevExpress().ComboBox(
            settings =>
            {
                settings.Name = "FDutyNo";
                settings.Properties.DropDownStyle = DropDownStyle.DropDownList;
                settings.Properties.TextField = "FCodeName";
                settings.Properties.ValueField = "FCodeNo";
                settings.Properties.ValidationSettings.EnableCustomValidation = true;
            }).BindList(ViewData["dutyNoList"]).Bind(Model.FDutyNo == null ? "-1" : Model.FDutyNo).GetHtml()
                </td>
            </tr>
            <tr>
                <th>
                    职责:
                </th>
                <td colspan="3" class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FJob";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.Text = Model.FJob;
               }).GetHtml()
                </td>
            </tr>
            <tr>
                <th>
                    显示顺序:
                </th>
                <td class="tdClass">
                    @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "FSeq";
                   settings.Width = System.Web.UI.WebControls.Unit.Percentage(96);
                   settings.Text = Model.FSeq.ToString();
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()
                </td>
                <th>
                    入职日期:
                </th>
                <td class="tdClass">
                    @Html.DevExpress().DateEdit(settings =>
               {
                   settings.Name = "FWorkDate";
                   settings.Properties.NullText = "";
                   settings.Properties.DisplayFormatString = "yyyy-MM-dd";
                   settings.Properties.EditFormatString = "yyyy-MM-dd";
                   if (Model.FWorkDate.HasValue)
                   {
                       settings.Date = Model.FWorkDate.Value;
                   }

               }).GetHtml()
                </td>
            </tr>
            <tr>
                <th>
                    员工状态:
                </th>
                <td class="tdClass">
                    @Html.DevExpress().ComboBox(
            settings =>
            {
                settings.Name = "FEmpStatus";
                settings.Properties.DropDownStyle = DropDownStyle.DropDownList;
                settings.Properties.TextField = "Text";
                settings.Properties.ValueField = "Value";
                //settings.Properties.ClientSideEvents.SelectedIndexChanged = "function(s,e){alert(s.GetValue());}";
            }).BindList(new List<SelectListItem> {
                new SelectListItem { Text = "试用", Value = "01" }, 
                new SelectListItem { Text = "正式", Value = "02" }, 
                new SelectListItem { Text = "离职", Value = "03" }, 
                new SelectListItem { Text = "退休", Value = "04" },
                new SelectListItem { Text = "停薪留职", Value = "05" } ,
                new SelectListItem { Text = "虚拟人员", Value = "99" } }).Bind(Model.FEmpStatus).GetHtml()
                </td>
                <th>
                    离职日期
                </th>
                <td class="tdClass">
                    @Html.DevExpress().DateEdit(settings =>
               {
                   settings.Name = "FLeaveDate";
                   settings.Properties.NullText = "";
                   settings.Properties.DisplayFormatString = "yyyy-MM-dd";
                   settings.Properties.EditFormatString = "yyyy-MM-dd";
                   if (Model.FLeaveDate.HasValue)
                   {
                       settings.Date = Model.FLeaveDate.Value;
                   }

               }).GetHtml()
                </td>
            </tr>
        </table>
    
        @Html.DevExpress().PopupControl(
    settings =>
    {
        settings.Name = "positonModalMode";
        settings.Width = 300;
        settings.Height = 430;
        settings.AllowDragging = true;
        settings.CloseAction = CloseAction.CloseButton;
        settings.EnableAnimation = false;
        settings.HeaderText = "岗位选择";
        settings.Modal = true;
        settings.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
        settings.PopupVerticalAlign = PopupVerticalAlign.WindowCenter;
        //settings.ContentUrl = "/Admin/Empl/PositionTree?positons=" + ViewData["deptPosition"];
        settings.ShowFooter = true;
        settings.SetFooterTemplateContent(s =>
        {
            ViewContext.Writer.Write("<table align='center'><tr><td>");
            @Html.DevExpress().Button(footBtnSettings =>
            {
                footBtnSettings.Name = "btnOK";
                footBtnSettings.Text = "确定";
                footBtnSettings.ClientSideEvents.Click = "function(s,e){popContent.OK()}";
                footBtnSettings.Images.Image.Url = Url.Content("~/Content/ControlImages/ok.png");
                footBtnSettings.CausesValidation = false;
            }).GetHtml();
            ViewContext.Writer.Write("</td><td>");
            @Html.DevExpress().Button(footBtnSettings =>
            {
                footBtnSettings.Name = "btnCancel";
                footBtnSettings.Text = "取消";
                footBtnSettings.ClientSideEvents.Click = "PositionCancel";
                footBtnSettings.Images.Image.Url = Url.Content("~/Content/ControlImages/no.png");
                footBtnSettings.CausesValidation = false;
            }).GetHtml();
            ViewContext.Writer.Write("</td></tr></table>");

        });
        settings.SetContent(() =>
        {
            ViewContext.Writer.Write("<iframe  id='popContent' name='popContent' style='width:100%;height:330px' frameborder='0' src='" + Url.Action("PositionTree", "Empl", new { positons = ViewData["deptPosition"] }) + "'></iframe>");
        });

    }).GetHtml()
        
        
        
        @Html.Hidden("hidSaveType", "save");//save 保存 saveAdd 保存并增加 deptPositionMain
        @Html.Hidden("hidDeptPosition", ViewData["deptPosition"])        
        @Html.Hidden("hidMessage", ViewData["message"])

        
    @Html.Hidden("hdTreeDeptNo", ViewData["treeDeptNo"]);
    @Html.Hidden("hdPageIndex", ViewData["pageIndex"]);
    }
    
    @Html.Hidden("hidDeptPositionHtml", ViewData["deptPositionHtml"])

    <script>
        lp.Hide();
    </script>

</body>
</html>
